	$(function(){
		$("#toLogin").click(function(){
			window.location.href = window.url.LOGIN;
			return false;
		})
		$("#registerForm").validate({
			rules: {
				loginName: {
					loginName: true,
					checkName: true
				},
				name: {
					nickname: true
				},
				plainPassword: {
					password: true
				}
			}
		});
		
		$("#registerSubmit").click(function(){
			var flag = $("#registerForm").valid();
			if(!flag)
				return false;
			var formParams = $("#registerForm").serialize();
			var url = window.url.REGISTER;
			$.post(url,formParams,function(result){
				if(result.code==0) {
					layer.msg("注册成功",{icon:1,time:700},function(){
						window.location.href = window.url.LOGIN;
					})
				}else if(result.code==1) {
					layer.alert(result.message,{icon:2})
					$("#captcha").click();
				}
			})
			return false;
		})
	})